package com.lz.ccjdemo.greendao.dao;

import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import org.greenrobot.greendao.query.Query;
import org.greenrobot.greendao.query.QueryBuilder;

import com.lz.ccjdemo.greendao.data.OperationProcessData;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "OPERATION_PROCESS_DATA".
*/
public class OperationProcessDataDao extends AbstractDao<OperationProcessData, Long> {

    public static final String TABLENAME = "OPERATION_PROCESS_DATA";

    /**
     * Properties of entity OperationProcessData.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Dish_id = new Property(1, Long.class, "dish_id", false, "DISH_ID");
        public final static Property Temperature_gear = new Property(2, String.class, "temperature_gear", false, "TEMPERATURE_GEAR");
        public final static Property Stir_gear = new Property(3, String.class, "stir_gear", false, "STIR_GEAR");
        public final static Property Warehouse_id = new Property(4, String.class, "warehouse_id", false, "WAREHOUSE_ID");
        public final static Property Seasoning = new Property(5, String.class, "seasoning", false, "SEASONING");
        public final static Property Thicken_with_starch = new Property(6, String.class, "thicken_with_starch", false, "THICKEN_WITH_STARCH");
        public final static Property Des = new Property(7, String.class, "des", false, "DES");
    }

    private Query<OperationProcessData> dishData_ProcessDataQuery;

    public OperationProcessDataDao(DaoConfig config) {
        super(config);
    }
    
    public OperationProcessDataDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"OPERATION_PROCESS_DATA\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"DISH_ID\" INTEGER," + // 1: dish_id
                "\"TEMPERATURE_GEAR\" TEXT," + // 2: temperature_gear
                "\"STIR_GEAR\" TEXT," + // 3: stir_gear
                "\"WAREHOUSE_ID\" TEXT," + // 4: warehouse_id
                "\"SEASONING\" TEXT," + // 5: seasoning
                "\"THICKEN_WITH_STARCH\" TEXT," + // 6: thicken_with_starch
                "\"DES\" TEXT);"); // 7: des
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"OPERATION_PROCESS_DATA\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, OperationProcessData entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long dish_id = entity.getDish_id();
        if (dish_id != null) {
            stmt.bindLong(2, dish_id);
        }
 
        String temperature_gear = entity.getTemperature_gear();
        if (temperature_gear != null) {
            stmt.bindString(3, temperature_gear);
        }
 
        String stir_gear = entity.getStir_gear();
        if (stir_gear != null) {
            stmt.bindString(4, stir_gear);
        }
 
        String warehouse_id = entity.getWarehouse_id();
        if (warehouse_id != null) {
            stmt.bindString(5, warehouse_id);
        }
 
        String seasoning = entity.getSeasoning();
        if (seasoning != null) {
            stmt.bindString(6, seasoning);
        }
 
        String thicken_with_starch = entity.getThicken_with_starch();
        if (thicken_with_starch != null) {
            stmt.bindString(7, thicken_with_starch);
        }
 
        String des = entity.getDes();
        if (des != null) {
            stmt.bindString(8, des);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, OperationProcessData entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        Long dish_id = entity.getDish_id();
        if (dish_id != null) {
            stmt.bindLong(2, dish_id);
        }
 
        String temperature_gear = entity.getTemperature_gear();
        if (temperature_gear != null) {
            stmt.bindString(3, temperature_gear);
        }
 
        String stir_gear = entity.getStir_gear();
        if (stir_gear != null) {
            stmt.bindString(4, stir_gear);
        }
 
        String warehouse_id = entity.getWarehouse_id();
        if (warehouse_id != null) {
            stmt.bindString(5, warehouse_id);
        }
 
        String seasoning = entity.getSeasoning();
        if (seasoning != null) {
            stmt.bindString(6, seasoning);
        }
 
        String thicken_with_starch = entity.getThicken_with_starch();
        if (thicken_with_starch != null) {
            stmt.bindString(7, thicken_with_starch);
        }
 
        String des = entity.getDes();
        if (des != null) {
            stmt.bindString(8, des);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public OperationProcessData readEntity(Cursor cursor, int offset) {
        OperationProcessData entity = new OperationProcessData( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // dish_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // temperature_gear
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // stir_gear
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // warehouse_id
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // seasoning
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // thicken_with_starch
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // des
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, OperationProcessData entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setDish_id(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setTemperature_gear(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setStir_gear(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setWarehouse_id(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setSeasoning(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setThicken_with_starch(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setDes(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(OperationProcessData entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(OperationProcessData entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(OperationProcessData entity) {
        return entity.getId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
    /** Internal query to resolve the "processData" to-many relationship of DishData. */
    public List<OperationProcessData> _queryDishData_ProcessData(Long dish_id) {
        synchronized (this) {
            if (dishData_ProcessDataQuery == null) {
                QueryBuilder<OperationProcessData> queryBuilder = queryBuilder();
                queryBuilder.where(Properties.Dish_id.eq(null));
                dishData_ProcessDataQuery = queryBuilder.build();
            }
        }
        Query<OperationProcessData> query = dishData_ProcessDataQuery.forCurrentThread();
        query.setParameter(0, dish_id);
        return query.list();
    }

}
